package edu.scau.hibernate.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

@SuppressWarnings("deprecation")
public final class HibernateUtil{
    private static SessionFactory sessionFactory;
    private HibernateUtil(){
    }
    //初始化
    static{
  	  Configuration cfg = new Configuration();
          cfg.configure();
   	  sessionFactory = cfg.buildSessionFactory();
    }    
    
    public static SessionFactory getSessionFactory(){
  	    return sessionFactory;
    }
   
    public static Session getSession(){
  	   return sessionFactory.openSession();
    }
    
}
